local hl_ex__huoji = fk.CreateSkill{
  name = "hl_ex__huoji",
}

Fk:loadTranslationTable{
  ["hl_ex__huoji"] = "火计",
  [":hl_ex__huoji"] = "你可以将一张红色手牌当【火攻】使用。你使用【火攻】时，观看牌堆顶的四张牌，然后可以弃置其中一张，代替此次需要弃置的手牌。",
  
  ["#hl_ex__huoji"] = "火计：你可以将一张红色手牌当【火攻】使用",
  ["#hl_ex__huoji-discard"] = "你可以从这些牌中弃置一张 %arg 牌，对 %src 造成1点火属性伤害",

  ["$hl_ex__huoji1"] = "赤焰飚发，焚轻舟，坠敌身。",
  ["$hl_ex__huoji2"] = "以火焚敌，乱其行阵。",
}

hl_ex__huoji:addEffect("viewas", {

  anim_type = "offensive",
  pattern = "fire_attack",
  prompt = "#hl_ex__huoji",
  handly_pile = true,
  card_filter = function(self, player, to_select, selected)
    return #selected == 0 and Fk:getCardById(to_select).color == Card.Red and table.contains(player:getHandlyIds(), to_select)
  end,
  view_as = function(self, player, cards)
    if #cards ~= 1 then return end
    local card = Fk:cloneCard("fire_attack")
    card.skillName = hl_ex__huoji.name
    card:addSubcard(cards[1])
    return card
  end,
})

hl_ex__huoji:addEffect(fk.PreCardEffect, {
  can_refresh = function(self, event, target, player, data)
    return player:hasSkill(hl_ex__huoji.name) and data.from == player and data.card.trueName == "fire_attack"
  end,
  on_refresh = function(self, event, target, player, data)
    local card = data.card:clone()
    local c = table.simpleClone(data.card)
    for k, v in pairs(c) do
      card[k] = v
    end
    
    card.skill = Fk.skills["hl_ex__huoji__fire_attack_skill"]
    data.card = card
  end,
})

return hl_ex__huoji
